<?php
/**
 * Password.php
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  BlogAdmin
 */

/** base class */
require_once 'Madoqua/Form.php';

/** md5 filter */
require_once 'Madoqua/Filter/Md5.php';

/** identical filter for pw */
require_once 'Zend/Validate/Identical.php';

/** field compare validator */
require_once 'Madoqua/Validate/FieldCompare.php';

/**
 * BlogAdmin_User_Password
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  BlogAdmin
 */
class BlogAdmin_User_Password extends Madoqua_Form
{
    /**
     * constructor
     *
     */
    public function __construct() 
    {
        parent::__construct();
        
        $oldPw = Zend_Auth::getInstance()->getIdentity()->password;

        $this->addElement('password', 'old_password', array(
            'label' => 'Old Password',
            'attribs' => array(
                'autocomplete' => 'off'
            ),
            'required' => true,
            'filters' => array(
                new Madoqua_Filter_Md5()
            ),
            'validators' => array(
                array('StringLength', 255, 2),
                new Zend_Validate_Identical($oldPw)
            )
        ));
        //old password field

        $this->addElement('password', 'new_password', array(
            'label' => 'New Password',
            'attribs' => array(
                'autocomplete' => 'off'
            ),
            'required' => true,
            'validators' => array(
                array('StringLength', 255, 6),
                new Madoqua_Validate_FieldCompare(array('new_password_c'))
            )        
        ));
        //new password
        
        $this->addElement('password', 'new_password_c', array(
            'label' => 'New Password (confirm)',
            'attribs' => array(
                'autocomplete' => 'off'
            ),
            'required' => true,
            'validators' => array(
                array('StringLength', 255, 6),
                new Madoqua_Validate_FieldCompare(array('new_password'))
            )        
        ));
        //new password compare field
        
        $this->addElement('submit', 's', array(
            'label' => 'Submit'
        ));
        
    }
}